#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e5+10;
int a[N];
long long he[N] = {0};
int n,x;
int mi = 0;
long long sum = 0;
int main() {
    cin >> n >> x;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(n<=x){
        cout << sum << endl;
    }else{
        sort(a+1,a+1+n);
        for(int i=1;i<=n;i++) he[i]=he[i-1]+a[i];;
        for(int i=n;i>=1;i--)
        {
            sum=min(sum,x*a[i]+he[n]-he[i]-a[i]*(n-i));
        }
        cout << sum << endl;
    }
    return 0;
}